package LeetCode.NumOffer;

/**
 * 二叉树的最大深度
 * @author lumin
 * @date 2022/03/18 12:13
 **/
public class NumOffer55 {
    public class TreeNode {
       int val;
       TreeNode left;
       TreeNode right;
       TreeNode(int x) { val = x; }
    }
    public int maxDepth(TreeNode root) {
        if(root == null){
            return 0;
        }
        int leftDepth = maxDepth(root.left);
        int rightDepth = maxDepth(root.right);
        int maxHeight = Math.max(leftDepth,rightDepth);
        return 1 + maxHeight;
    }
}